// 定义一个User
/* class User {
    public username:string | undefined;
    public password:string | undefined;
}

class mysqlDb {
    add(user: User):boolean {
        console.log(user);
        return true
    }
}
let u = new User()
u.username = 'zs';
u.password = '123456';

let m = new mysqlDb();
m.add(u); */
/* class ArticleCate {
    title:string | undefined;
    desc:string | undefined;
    status:number | undefined;
}

class mysqlDb {
    add(info: ArticleCate):boolean {
        console.log(info);
        return true
    }
}

let a = new ArticleCate();
a.title= "大神"
a.desc = "很厉害"
a.status = 1
const m = new mysqlDb()
m.add(a) */
// 上面没操作就要写一次
// ============ 泛型实现以上内容 ==============
// class mysqlDb<T> {
//     add(info:T):boolean {
//         console.log(info);
//         return true
//     }
// }
// 想给表增加数据
// 1.定义一个User类，和数据库映射
/* class User {
    username:string | undefined;
    password:string | undefined;
}

let u = new User()
u.username = 'zs';
u.password = '123456';
let m = new mysqlDb<User>();
m.add(u) */
/* class ArticleCate {
    title:string | undefined;
    desc:string | undefined;
    status:number | undefined;
    constructor(params:{
        title:string | undefined
        desc:string | undefined,
        status?:number | undefined
    }){
        this.title = params.title;
        this.desc = params.desc;
        this.status = params.status;
    }
}
class mysqlDb<T> {
    add(info: T):boolean {
        console.log(info);
        return true
    }
}

var a = new ArticleCate({
    title:'分类',
    desc: '111'
})

var Db = new mysqlDb<ArticleCate>()
Db.add(a) */
// 身份证正面 1，身份证反面 2，行驶证正面 3，行驶证副页4 ，驾驶证正页5，驾驶证副页 6，银行卡 7，
/* interface DBI<T> {
    add(info:T):boolean;
    updated (info:T, id:number):boolean;
    delete(id:number):boolean;
    get(id:number):any[];
} */
// 定义一个操作mysql数据库的类
// 注意:要实现泛型接口，这个类应该也是一个泛型类
/* class MysqlDb<T> implements DBI<T> {
    add(info: T): boolean {
        console.log(info);
        return true;
    }
    updated(info: T, id: number): boolean {
        throw new Error("Method not implemented.");
    }
    delete(id: number): boolean {
        throw new Error("Method not implemented.");
    }
    get(id: number): any[] {
        throw new Error("Method not implemented.");
    }
} */
//定义一个操作mssql数据库的类
/* class MsSqlDb<T> implements DBI<T> {
    add(info: T): boolean {
        console.log(info);
        return true;
    }
    updated(info: T, id: number): boolean {
        throw new Error("Method not implemented.");
    }
    delete(id: number): boolean {
        throw new Error("Method not implemented.");
    }
    get(id: number): any[] {
        throw new Error("Method not implemented.");
    }
} */
// 操作用户表 定义一个user类和数据表做映射
/* class User {
    username:string | undefined;
    password:string | undefined;
}

let u =new User();
u.username = '张三';
u.password = '123456';

var oMysql = new MysqlDb<User>(); //将类作为传入数据的合法性
oMysql.add(u) */
/* class User {
    username:string | undefined;
    password:string | undefined;
}

let u =new User();
u.username = '张三';
u.password = '123456';

let oMssql = new MsSqlDb<User>()
oMssql.add(u) */
